﻿@model Products.Databases.Table
@{    
    
    ViewBag.Title = this.Model.Name;
    Layout = "../Shared/VersionPage.cshtml";
    var fieldList = (IList<Products.Databases.Field>)ViewData["Fields"];
}
@section buttons{
    @Html.ActionLink("Create Field", "Create", "Field", new { id = this.Model.Id }, new { Id = "CreateField" })
    @Html.ActionLink("Delete", "Delete", new { id = this.Model.Id }, new { id = "DeleteTable" })
}
<div class="cssform">
    <textarea readonly="readonly" style="width: 100%">@Model.Memo</textarea>
</div>
<hr />
@Html.Partial("../Shared/DisplayStateController")
<table style="width: 100%; margin: 0 auto">
    <thead>
        <tr>
            <th>
            </th>
            <th>
                Name
            </th>
            <th>
                Type
            </th>
            <th>
                Length
            </th>
            <th>
                Memo
            </th>
            <th>
                Current Version
            </th>
        </tr>
    </thead>
    <tbody class="DisplayState">
        @foreach (var field in fieldList)
        {            
            <tr class="@field.DisplayState.ToString().Replace(",", " ")">
                <th style="width: 150px">
                    @Html.ActionLink("New Change", "NewChange", "Field", new { Id = field.Id }, null)|
                    @Html.ActionLink("Edit", "Edit", "Field", new { Id = field.CurrentSnapshot.Id }, new { Title = "edit field at version " + field.CurrentSnapshot.Version })
                </th>
                <td>
                    @field.Name
                </td>
                <td>
                    @field.SqlType
                </td>
                <td>
                    @field.Length
                </td>
                <td>
                    @this.Html.Raw(field.Memo)
                </td>
                <td>
                    @field.CurrentSnapshot.Version.Name
                </td>
            </tr>
        }
    </tbody>
</table>
@section Header{
    <script type="text/javascript">
        $(document).ready(function () {
            $("#CreateField").button();
            $("#DeleteTable").button();
        });
    </script>
}
@section PageTitle{
    @Html.ActionLink(this.Model.Product.Name, "Index", new { product = this.Model.Product.Name, version = this.Model.Product.Versions[0] }, null)
    : @this.Model.Name
}
